﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACAWebThumbLib;

namespace Deloitte
{
    public class HtmlToJpegConverter
    {
        ThumbMakerClass jpegConverter = null;
        public HtmlToJpegConverter()
        {
            
        }

        public void ConvertHtmlToJpg(string url, string jpgSavePath)
        {
            try
            {
                long t_iResult = 0;
                bool t_bRet1 = false;
                ThumbMakerClass jpegConverter = new ACAWebThumbLib.ThumbMakerClass();
                jpegConverter.SetURL(url);
                t_iResult = jpegConverter.StartSnap();
                if (0 == t_iResult)
                {
                    t_bRet1 = jpegConverter.SaveImage(jpgSavePath);

                }
                else
                {
                    throw new Exception("Error: Snap from " + url + " failed. Error code: " + t_iResult);
                }
            }
            catch (Exception)
            {

                throw new Exception("Error: Snap from " + url + " failed.");
            }
        }

    }
}
